package gupao.concurrency.lock;

import gupao.concurrency.lock.utils.Utils;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

@Slf4j
public class ConditionSample {

    public static void main(String[] args) throws InterruptedException {
        Lock lock = new ReentrantLock();
        Condition c = lock.newCondition();
        new Thread(() -> {
            Utils.sleepIgnoreExp(20000);
            lock.lock();
            log.info("c.signalAll...");
            c.signalAll();
            lock.unlock();
        }).start();


        lock.lock();
        log.info("c.await...");
        c.await();
        log.info("aaa");
        lock.unlock();
    }
}
